home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 119_01.zip / COMM4.C < prev    next >
Text File  |  1993-06-16  |  6KB  |  221 lines

  1. /* Modifications Record:
  2.         10/04/81    Moved in MCIndent and MSInsert from Comm1.C, so
  3.                 that they always get compiled but only get linked
  4.                     in if they are referenced in CBIND.C (BAD). In order
  5.                 to get MSInsert to work, i added a new global in_cnt
  6.                 after the 1100 reserved integers in Mince.GBL .
  7.                     The last few lines look like this now:
  8. int spare[10];
  9.  
  10. char _reserved[1100];    /* Mark of the Unicorn's extra externals that we 
  11.                        are not allowed to use any of. See AUG 1.4 for
  12.                        more details. 10-3-81 BAD */
  13.  
  14. #ifdef LARGE
  15. unsigned in_cnt;
  16. #endif
  17.  
  18. /* END OF MINCE.GBL - Global variable definitions for Mince. */
  19. -------------------------------------------------------------------------------
  20.         07/23/81  Moved out MNewDsp, MSearch, MRSearch which all
  21.                     appear in CBIND.C and moved all the Page
  22.                     mode functions, for space. Moved functions appear
  23.                     in COMM4.C, and are linked immediately AFTER the
  24.                     -l option in L2.  Bad.
  25. -------------------------------------------------------------------------------
  26.         07/22/81    Added MNewDisp() which gets bound to C-L; the
  27.                     purpose of MNewDsp() is to prevent any arguments to
  28.                     a C-L from causing it to hang doing lots of senseless
  29.                     work. I.E. the arg to MNewDsp is thrown away, and only
  30.                     one NewDsp is ever done. BAD.
  31.  
  32. */
  33.  
  34. /* COMM4.C    This is an optional part of the mince command set
  35.  
  36. The seller of this software hereby disclaim any and all
  37. guarantees and warranties, both express and implied.  No
  38. liability of any form shall be assumed by the seller, nor shall
  39. direct, consequential, or other damages be assumed by the seller.
  40. Any user of this software uses it at his or her own risk.
  41.  
  42. Due to the ill-defined nature of "fitness for purpose" or similar
  43. types of guarantees for this type of product, no fitness for any
  44. purpose whatsoever is claimed or implied.
  45.  
  46. The physical medium upon which the software is supplied is
  47. guaranteed for one year against any physical defect.  If it
  48. should fail, return it to the seller, and a new physical medium
  49. with a copy of the purchased software shall be sent.
  50.  
  51. The seller reserve the right to make changes, additions, and
  52. improvements to the software at any time; no guarantee is made
  53. that future versions of the software will be compatible with any
  54. other version.
  55.  
  56. The parts of this disclaimer are severable and fault found in any
  57. one part does not invalidate any other parts.
  58.  
  59.     Copyright (c) 1981 by Mark of the Unicorn
  60.     Created for version two  8/27/80  JTL
  61.     Updated to version three  1/7/81  JTL
  62.  
  63.     This file contains auxilliary (optional) command execution
  64. routines for the mince editor. There are also a small number of
  65. subordinate routines. */
  66.  
  67. #include "mince.gbl"
  68.  
  69.     /* Page mode commands */
  70. MOverwrite()            /* overwrite instead of inserting */
  71. {
  72.     if (!BIsEnd() && !IsNL()) {
  73.         MPFChar();
  74.         BMove(-1);
  75.         BDelete(1);
  76.         }
  77.     BInsert(cmnd);
  78.     }
  79.  
  80. MPBegLine()            /* move to the first non-white character */
  81. {
  82.     int IsWhite();
  83.  
  84.     ToBegLine();
  85.     MovePast(IsWhite,FORWARD);
  86.     if (IsNL()) MDelWhite();
  87.     }
  88.  
  89. MPBChar()                /* move to the left one character */
  90. {
  91.     ForceCol(BGetCol()-1,BACKWARD);
  92.     }
  93.  
  94. MPFChar()                /* move to the right one character */
  95. {
  96.     ForceCol(BGetCol()+1,FORWARD);
  97.     }
  98.  
  99. MPEndLine()            /* go to end of line less white space */
  100. {
  101.     ToEndLine();
  102.     MDelWhite();
  103.     }
  104.  
  105. MPBackSpace()            /* rub out previous character */
  106. {
  107.     if (BGetCol()==0) return;
  108.     MPBChar();
  109.     if (!BIsEnd() && !IsNL()) {
  110.         MPFChar();
  111.         BMove(-1);
  112.         BDelete(1);
  113.         }
  114.     BInsert(' ');
  115.     BMove(-1);
  116.     }
  117.     
  118. MPTab()                /* move over a tab stop */
  119. {
  120.     ForceCol(BGetCol()+TWidth(BGetCol(),TAB),FORWARD);
  121.     }
  122.  
  123. MPNextLine()            /* move to the next line in exact same column */
  124. {
  125.     MNextLin();
  126.     ForceCol(lcol,FORWARD);
  127.     }
  128.  
  129. MPPrevLine()            /* move to previous column in same column */
  130. {
  131.     MPrevLin();
  132.     ForceCol(lcol,FORWARD);
  133.     }
  134.  
  135.     /* End of Page mode commands*/ 
  136.  
  137. MNewDsp()                /* redisplay hack so that redisplay with an arg */
  138.                     /* only calls NewDsp() once. (BAD) */
  139. {
  140.     NewDsp();
  141.     arg = 0;
  142.     }
  143.  
  144. MRSearch()            /* reverse string search */
  145. {
  146.     if (!GetArg("Reverse Search <ESC>: ",ESC,strarg,STRMAX)) {
  147.         arg=0;
  148.         return;
  149.         }
  150.     tmark=BCreMrk();
  151.     while (arg-- > 0) if (!StrSrch(strarg,BACKWARD)) {
  152.         BPntToMrk(tmark);
  153.         Error("Not Found");
  154.         break;
  155.         }
  156.     BKillMrk(tmark);
  157.     arg=0;
  158.     ClrEcho();
  159.     }
  160.  
  161. MSearch()                /* forward string search */
  162. {
  163.     if (!GetArg("Forward Search <ESC>: ",ESC,strarg,STRMAX)) {
  164.         arg=0;
  165.         return;
  166.         }
  167.     tmark=BCreMrk();
  168.     while (arg-- > 0) if (!StrSrch(strarg,FORWARD)) {
  169.         BPntToMrk(tmark);
  170.         Error("Not Found");
  171.         break;
  172.         }
  173.     BKillMrk(tmark);
  174.     arg=0;
  175.     ClrEcho();
  176.     }
  177.  
  178.  
  179.     /* C Mode commands */
  180. MCIndent()            /* Indent for C code */
  181. {
  182.     int IsWhite(), wid;
  183.  
  184.     tmark=BCreMrk();
  185.     ToBegLine();
  186.     MovePast(IsWhite,FORWARD);
  187.     if (BIsAfter(tmark)) BPntToMrk();
  188.     wid=BGetCol();
  189.     while (BIsBefore(tmark)) {
  190.         if (Buff()=='{') wid += indentcol;
  191.         else if (Buff()=='}') wid -= indentcol;
  192.         BMove(1);
  193.         TKbChk();
  194.         }
  195.     BPntToMrk(tmark);
  196.     BKillMrk(tmark);
  197.     BInsert(NL);
  198.     TIndent(wid);
  199.     }
  200.  
  201.     /* Auto save mode */
  202. MSInsert()            /* Auto save self insert */
  203. {
  204. /*    static unsigned in_cnt;   i put this in mince.gbl 10-3-81 BAD */
  205.  
  206.     BInsert(cmnd);
  207.     if (++in_cnt>256) {
  208.         MFileSave();
  209.         in_cnt=0;
  210.         }
  211.     }
  212.  
  213. /* END OF COMM4.C */        }
  214.     BKillMrk(tmark);
  215.     arg=0;
  216.     ClrEcho();
  217.     }
  218.  
  219. MSearch()                /* forward string search */
  220. {
  221.     if (!